EJERCICIO 1¶
In [ ]:
#!pip install geopandas
In [ ]:
#!pip install fiona
Lectura de datos y proyecciones
In [ ]:
import geopandas as gpd
from fiona import listlayers
countries=gpd.read_file('https://github.com/Tracy-12/TAREA_GRUPAL_2/raw/refs/heads/main/maps/World_Countries/World_Countries.shp')
public_hospitals=gpd.read_file('https://github.com/Tracy-12/TAREA_GRUPAL_2/raw/refs/heads/main/Public_hospitals/Public_Hospitals.shp')
eletricity_lines=gpd.read_file('https://github.com/Tracy-12/TAREA_GRUPAL_2/raw/refs/heads/main/Electricity_Transmission_lines/Electricity_Transmission_Lines.shp')
australia_states=gpd.read_file('https://github.com/Tracy-12/TAREA_GRUPAL_2/raw/refs/heads/main/states%20and%20territories%20aus/STE_2021_AUST_GDA2020.shp')
WorldMap="https://github.com/CienciaDeDatosEspacial/intro_geodataframe/raw/main/maps/worldMaps.gpkg"
indicators=gpd.read_file(WorldMap,layer='indicators')
In [ ]:
australia=countries[countries.COUNTRY=='Australia']
australia_3112=australia.to_crs(3112)
Primero se le asigna un crs conocido y luego se proyecta las variables
In [ ]:
public_hospitals = public_hospitals.set_crs(epsg=4326, allow_override=True)
public_hospitals_clipped=gpd.clip(public_hospitals,australia)
public_hospitals_3112=public_hospitals_clipped.to_crs(3112)
In [ ]:
eletricity_lines = eletricity_lines.set_crs(epsg=4326, allow_override=True)
eletricity_lines_clipped=gpd.clip(eletricity_lines,australia)
eletricity_lines_3112=eletricity_lines_clipped.to_crs(3112)
In [ ]:
australia_states = australia_states.set_crs(epsg=4326, allow_override=True)
australia_states_clipped=gpd.clip(australia_states,australia)
australia_states_3112=australia_states_clipped.to_crs(3112)
In [ ]:
#Centroide
australia_centroid=australia.to_crs(3112).centroid
centroidX,centroidY=australia_3112.centroid.x.values[0],australia_3112.centroid.y.values[0]
# the arriba
australia_states_A=australia_states_3112.cx[:,centroidY:]
# the abajo
Public_hospitals_B=public_hospitals_3112.cx[:,:centroidY]
- Se muestran los puntos por debajo del centroide
In [ ]:
base = australia_3112.plot(facecolor="lightblue", edgecolor='black', linewidth=0.4,figsize=(5,5))
Public_hospitals_B.plot(marker='.', color='blue', markersize=13,
ax=base)
Out[Â ]:
<Axes: >
- Se muestran las lineas que cruzan los estados por encima del centroide
In [ ]:
australia_states_A.plot(facecolor="lightblue", edgecolor='black', linewidth=0.4,figsize=(5,5))
Out[Â ]:
<Axes: >
In [ ]:
base = australia_3112.plot(facecolor="lightblue", edgecolor='black', linewidth=0.4,figsize=(5,5))
australia_states_A.plot(facecolor="lightblue", edgecolor='black', linewidth=1,
ax=base)
eletricity_lines_3112.plot(edgecolor='purple', linewidth=0.5,
ax=base)
Out[Â ]:
<Axes: >
EJERCICIO 2¶
In [ ]:
import geopandas as gpd
local_gov=gpd.read_file('https://github.com/Tracy-12/TAREA_GRUPAL_2/raw/refs/heads/main/local_goverment%20areas/SA4_2021_AUST_GDA94.shp')
local_gov.head()
Out[Â ]:
| SA4_CODE21 | SA4_NAME21 | CHG_FLAG21 | CHG_LBL21 | GCC_CODE21 | GCC_NAME21 | STE_CODE21 | STE_NAME21 | AUS_CODE21 | AUS_NAME21 | AREASQKM21 | LOCI_URI21 | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 101 | Capital Region | 0 | No change | 1RNSW | Rest of NSW | 1 | New South Wales | AUS | Australia | 51896.2444 | http://linked.data.gov.au/dataset/asgsed3/SA4/101 | MULTIPOLYGON (((150.0526 -37.26254, 150.05251 ... |
| 1 | 102 | Central Coast | 0 | No change | 1GSYD | Greater Sydney | 1 | New South Wales | AUS | Australia | 1681.0088 | http://linked.data.gov.au/dataset/asgsed3/SA4/102 | MULTIPOLYGON (((151.31496 -33.55579, 151.31496... |
| 2 | 103 | Central West | 0 | No change | 1RNSW | Rest of NSW | 1 | New South Wales | AUS | Australia | 70297.0600 | http://linked.data.gov.au/dataset/asgsed3/SA4/103 | POLYGON ((150.14235 -32.34155, 150.14254 -32.3... |
| 3 | 104 | Coffs Harbour - Grafton | 0 | No change | 1RNSW | Rest of NSW | 1 | New South Wales | AUS | Australia | 13229.7577 | http://linked.data.gov.au/dataset/asgsed3/SA4/104 | MULTIPOLYGON (((153.07639 -30.42984, 153.07644... |
| 4 | 105 | Far West and Orana | 0 | No change | 1RNSW | Rest of NSW | 1 | New South Wales | AUS | Australia | 339355.6461 | http://linked.data.gov.au/dataset/asgsed3/SA4/105 | POLYGON ((148.67618 -29.50977, 148.67661 -29.5... |
In [ ]:
#se proyecta la variable de local goverment areas
local_gov=local_gov.set_crs(epsg=4326, allow_override=True)
local_gov_clipped=gpd.clip(local_gov,australia)
local_gov_3112=local_gov_clipped.to_crs(3112)
In [ ]:
local_gov_3112.plot()
Out[Â ]:
<Axes: >
In [ ]:
#numero de municipios
len(local_gov_3112.SA4_NAME21)
Out[Â ]:
89
In [ ]:
#numero de estados
len(set(local_gov_3112.STE_NAME21))
Out[Â ]:
9
In [ ]:
! pip show shapely
Name: shapely Version: 2.1.1 Summary: Manipulation and analysis of geometric objects Home-page: Author: Sean Gillies Author-email: License: BSD 3-Clause Location: /usr/local/lib/python3.11/dist-packages Requires: numpy Required-by: bigframes, geopandas, google-cloud-aiplatform, libpysal
- Se crea un subconjunto de poligonos del estado de New South Wales, con la funcion union
In [ ]:
local_gov_3112[local_gov_3112.STE_NAME21=='New South Wales'].plot()
Out[Â ]:
<Axes: >
In [ ]:
local_gov_3112[local_gov_3112.STE_NAME21=='New South Wales'].union_all()
Out[Â ]: